import Cookies from 'js-cookie'

const TokenKey = 'vue_admin_template_token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// 设置 user 对象到本地存储
export function setUser(user) {
  localStorage.setItem('user', JSON.stringify(user))
}

// 从本地存储中获取 user 对象
export function getUser() {
  const user = localStorage.getItem('user')
  return user ? JSON.parse(user) : null
}
